package com.secsbrain.development.dal.config;

import com.secsbrain.frame.lock.zk.ZkClusterFactory;
import com.secsbrain.frame.lock.zk.ZkDistributedLockTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Deprecated
//@Configuration
public class ZkConfig {

	@Value("${zookeeper.address}")
	private String zookeeperAddress;
	
	@Bean("zkClusterFactory")
	public ZkClusterFactory zkClusterFactory(){
		ZkClusterFactory zkClusterFactory=new ZkClusterFactory();
		zkClusterFactory.setConnStr(zookeeperAddress);
		return zkClusterFactory;
	}

	@Bean
	public ZkDistributedLockTemplate zkDistributedLockTemplate() throws Exception {
		ZkDistributedLockTemplate zkDistributedLockTemplate=new ZkDistributedLockTemplate(zkClusterFactory().getObject());
		return zkDistributedLockTemplate;
	}

}
